<template>
  <div class="about">
    <div class="head" style="display: flex;
  justify-content:space-between;
  flex-wrap:wrap;
  align-items:center;">
          <div class="div" style="display:flex;align-items:center;" @click="$router.go(-1)">
                <img src="../../assets/image/返回白@2x.png" alt="" class="percen">
                <span class="sapn1" style="color:#fff;">返回</span>
      </div>
        <div class="div csgo">
            <span class="sapn2" style="color:#fff;">新建康复服务评价</span>
        </div>
        <div class="div cs" style="display:flex;align-items:center;" @click="ao()">
          <span class="sapn1" style="color:#fff;">保存</span>
      </div>
    </div>
    <div class="main">
        <div class="choes">
            <span style="width:100px;">评价年度</span>
            <div class="left" @click="show1=true">
                <strong style="text-align: right;">{{main1}}</strong>
                <img src="../../assets/image/下拉灰@2x.png" alt="">
            </div>
            <van-popup v-model="show1" round position="bottom" :style="{ height: '46%' }">
                 <van-picker show-toolbar :columns="columns" title="选择年度" @cancel="show1=false" @confirm="onConfirm($event)"/>
            </van-popup>
        </div>
        <div class="xian"></div>
        <div class="sa clear">
            <span>康复服务满意程度</span>
        <van-radio-group v-model="radio" class="aa" direction="horizontal">
            <van-radio name="1" class="van">非常满意</van-radio>
            <van-radio name="2" class="van">满意</van-radio>
            <van-radio name="3" class="van">不满意</van-radio>
        </van-radio-group>
        </div >
        <div class="xian"></div>
        <div class="choes clear">
           <span style="width:154px;">
               残疾人或监护人(签名)
           </span>
           <div class="ox" @click="goname1()">
              <span style="width:90px;margin-right:20px;text-align: right;">{{qq1}}</span>
              <img src="../../assets/image/更多灰@2x.png" alt="">
           </div>
        </div>
        <div class="xian"></div>
         <div class="sa clear">
            <span style="margin-right:5px;">服务效果</span>
        <van-radio-group v-model="radio1" class="aa" direction="horizontal">
            <van-radio name="1" class="van">优良</van-radio>
            <van-radio name="2" class="van">一般</van-radio>
            <van-radio name="3" class="van">较差</van-radio>
        </van-radio-group>
        </div >
        <div class="xian"></div>
        <div class="choes clear" style="height:88px;">
            <div class="stel" style="height:88px;line-height: 30px;">下年度康复服务 建议(文字描述)</div>
            <textarea style="height:70px;margin-top:10px;width:200px;line-height: 20px;background-color: #FAF9FE;margin-top:5px;background-color: #FAF9FE;" placeholder="无" v-model="xox"></textarea>
        </div>
        <div class="xian"></div>

        <div class="choes">
            <span style="width:100px;">填写日期</span>
            <div class="left" @click="show=true">
                <strong style="text-align: right;">{{main}}</strong>
                <img src="../../assets/image/下拉灰@2x.png" alt="">
            </div>
            <van-popup v-model="show" round position="bottom" :style="{ height: '46%' }">
                <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate" title="选择日期" @confirm="chaa($event)" @cancel="show =false"/>
            </van-popup>
        </div>
        <div class="xian"></div>
         <div class="choes clear">
           <span style="width:154px;">
               评估人(签名)
           </span>
           <div class="ox" @click="goname()">
              <span style="width:90px;margin-right:20px;text-align: right;">{{qq2}}</span>
              <img src="../../assets/image/更多灰@2x.png" alt="">
           </div>
        </div>
        <div class="xian"></div>
    </div>
  </div>
</template>
<script>
import {litationEvaluation, EvaluationOrderBy} from '../../apiCanJi/apiCanji'

export default {
  data () {
    return {
      minDate: new Date(1000, 0, 1),
      maxDate: new Date(),
      currentDate: new Date(),
      main: '输入日期',
      show: false,
      show1: false,
      main1: '2020年度',
      columns: ['2020年度', '2019年度', '2018年度', '2017年度', '2016年度', '2015年度', '2014年度', '2013年度', '2012年度', '2011年度', '2010年度'],
      radio: '1',
      radio1: '1',
      ig1: '',
      ig2: '',
      xox: '',
      qq1: '去签名',
      qq2: '去签名'

    }
  },
  methods: {
    chaa (e) {
      this.show = false
      this.main = this.formatDate(this.currentDate)
    },
    onConfirm (e) {
      console.log(e)
      this.show1 = false
      this.main1 = e
    },
    goname () {
      this.$router.push('goname?id=' + 2)
      var str = JSON.stringify({
        main1: this.main1,
        radio: this.radio,
        radio1: this.radio1,
        xox: this.xox,
        main: this.main
      })
      localStorage.msg1 = str
    },
    goname1 () {
      this.$router.push('goname?id=' + 1)
      var str = JSON.stringify({
        main1: this.main1,
        radio: this.radio,
        radio1: this.radio1,
        xox: this.xox,
        main: this.main
      })
      localStorage.msg1 = str
    },
    formatDate (date) {
      // eslint-disable-next-line no-redeclare
      var date = new Date(date)
      var YY = date.getFullYear() + '-'
      var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate())
      // var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
      // var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
      // var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())
      return YY + MM + DD
    },
    aa () {
      var is1 = localStorage.img
      var is2 = localStorage.img1
      var msg1 = localStorage.msg1
      //  var obj = JSON.parse(str);
      if (is1 === undefined || is1 === '{"img":""}') {
        this.ig1 = ''
        this.qq1 = '去签名'
      } else {
        this.ig1 = JSON.parse(is1).img
        //  this.ig2.toString()
        this.qq1 = '修改签名'
      }
      if (is2 === undefined || is2 === '{"img":""}') {
        this.ig2 = ''
        this.qq2 = '去签名'
      } else {
        this.ig2 = JSON.parse(is2).img
        //  this.ig2.toString()
        this.qq2 = '修改签名'
      }
      if (msg1 === undefined || msg1 === '') {
        this.main1 = '2020年度',
        this.radio = '1',
        this.radio1 = '1',
        this.xox = '',
        this.main = '输入日期'
      } else {
        this.main1 = JSON.parse(msg1).main1,
        this.radio = JSON.parse(msg1).radio,
        this.radio1 = JSON.parse(msg1).radio1,
        this.xox = JSON.parse(msg1).xox,
        this.main = JSON.parse(msg1).main
      }
    },
    ao () {
      // console.log(11);

      var id = this.$route.query.id
      var id1 = JSON.parse(localStorage.disid).id
      EvaluationOrderBy({dpid: id1}).then(res => {
        //    console.log(res[2]);
        var a = false
        for (let i = 0; i < res.length; i++) {
          if (this.main1 === res[i].pingjianiandu) {
            a = true
            break
          } else {
            a = false
          }
        }
        if (a === true) {
          this.$toast('已存在该年度!')
        } else if (this.qq1 == '去签名') {
          this.$toast('残疾人或监护人未签名!')
        } else if (this.main == '' || this.main == '输入日期') {
          this.$toast('请填写日期!')
        } else if (this.xox == '') {
          this.$toast('请填写服务建议!')
        } else if (this.qq2 == '') {
          this.$toast('评估人未签名!')
        } else {
          litationEvaluation({
            id: '',
            dpid: id1,
            pingjianiandu: this.main1,
            manyichengdu: this.radio - 1,
            file: this.ig1,
            fuwuxiaoguo: this.radio1 - 1,
            fuwujianyi: this.xox,
            pinggutime: this.main,
            file2: this.ig2
          }).then(res => {
            this.$router.push('ass')
          })
          var str = JSON.stringify({
            main1: '2020年度',
            radio: '1',
            radio1: '1',
            xox: '',
            main: '输入日期' })
          localStorage.msg1 = str
          var str1 = JSON.stringify({img: ''})
          localStorage.img = str1
          var str2 = JSON.stringify({img: ''})
          localStorage.img1 = str2
          // this.$router.push('ass')

          this.qq1 = '去签名'
          this.qq2 = '去签名'
        }
      })
    }
  },
  mounted () {
    document.body.style.backgroundColor = '#FAF9FE'
  },
  created () {
    this.aa()
    document.title = '新建康复服务评价'
  }
}
</script>
<style scoped>
.clear:after {
  content: "";
  display: block;
  clear: both;
}
.clear {
  zoom: 1;
}
.head{
  width: 100%;
  height: 44px;
  background: linear-gradient(90deg, #1DA3F1 0%, #1DC7F1 100%);
  position: fixed;
  top:0px;
  z-index:100;
}
.about{
    position: relative;
}
.percen{
  width: 15px;
  height: 15px;
  margin: 0px 5px 0px 15px;
}
.div {
  font-size: 15px;
  font-weight: bold;

}
.head .percen{
  width: 7px;
  height: 13px;
  margin: 0px 5px 0px 15px;
}
.cs{
    float: right;
    margin-right: 14.5px;
}
.choes{
    width: 100%;
    height: 44px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    line-height: 44px;
}
.choes span{
    width: 60px;
    margin-left: 15px;
    margin-right: 15px;
    float: left;
}
.choes strong{
    width: 88px;
    margin-left: 15px;
    margin-right: 15px;
    float: left;
    color: #333;
    font-weight: normal;
}
.aa{

    font-size: 15px;
    margin-bottom: 10px;
}
.van{
    margin-right: 53.5px;
}
.left{
   float: right;
   margin-right: 19px;
}
.left span{
    margin-right: 12.2px;
    color: #999;

}
.left img{
    width: 13px;
    height: 7px;
}
.xian{
    width: 92%;
    border-top: 0.5px solid #000;
    transform:scaleY(0.25);
    margin-left: 15px;
}
.ox{
    float: right;
}
.ox img{
    width: 7px;
    height: 13px;
    margin-right: 19px;
}
.stel{
    width: 114px;
height: 41px;
font-size: 15px;
font-family: PingFang SC;
font-weight: 500;
color: #333333;
    margin-left: 15px;

    float: left;

}
input{
    float: left;
}
.main{
  margin-top: 44px;
  background-color: #fff;
}
.van{
  margin-top: 14px;
  float: left;
  margin-right: 40px;
}

 .sa span{
  width: 65px;
  margin-right: 2vw;
  font-weight: 500;
  color: #333333;
  font-size: 15px;
  float: left;
  margin-top: 15px;
  margin-left: 15px;
}
.sa1 span{
  width: 40px;
  font-weight: 500;
  color: #333333;
  font-size: 15px;
  float: left;
  margin-top: 15px;
  margin-left: 15px;
  margin-right: 0px;
}
/deep/ .van-picker__confirm{
    color: #1DA4F2 !important;
}
</style>
